<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "goods".
 *
 * @property int $id
 * @property string $name
 * @property string $price
 * @property string $stock
 * @property int $starttime
 * @property int $endtime
 * @property string $path
 */
class Goods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'string', 'max' => 30],
            [['price'], 'string', 'max' => 5],
            [['stock'], 'string', 'max' => 10],
            [['starttime', 'endtime'], 'string', 'max' => 4],
            [['path'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'price' => 'Price',
            'stock' => 'Stock',
            'starttime' => 'Starttime',
            'endtime' => 'Endtime',
            'path' => 'Path',
        ];
    }
    //获取所有商品表的数据
    public function getAll(){
        return  Goods::find()->asArray()->all();
    }
}
